﻿* Encoding: UTF-8.
***** NOTE: The following syntax was used to perform the necessary data management for the POQ article. 
*** Furthermore, the syntax computes the tables based on which Figures 8 and 9 were created.

****** To make the resulting ESS file smaller, all ESS Rounds, countries and variables not used in the article were dropped from the dataset.
*** Selecting the 18 countries for the POQ article.
select if cntry = "BE" or cntry = "DE" or cntry = "ES"  or cntry = "FI"  or cntry = "FR"  or cntry = "GB"  or cntry = "HU"  or cntry = "CH"  or cntry = "IE" 
or cntry = "NL"  or cntry = "NO"  or cntry = "PL"  or cntry = "PT"  or cntry = "SE"  or cntry = "SI"  or cntry = "CZ"  or cntry = "DK"  or cntry = "EE" .
fre cntry.
cro cntry by essround.

*** Selecting only ESS Rounds 4 and 8 (which contain special questions from the Welfare Attitudes module).
select if essround = 4 or essround = 8.
fre essround.

*** Loading the reduced ESS cumulative dataset (Rounds 4 and 8 and 18 analysed countries).
GET 
  FILE='C:\Users\ivan.petrusek\Desktop\Public Opinion Quarterly\REPLICATION FILES\ESS1-9e01_1_Rounds_4_and_8.sav'.

*** Weighting the dataset by Post-stratification weight including design weight (variable pspwght).
weight by pspwght.


*** Recoding two variables (i.e. beliefs in meritocracy and egalitarianism) into 0/1 variables.
fre dfincac smdfslv.
* Meritocracy.
recode dfincac (1 2 = 1) (3 4 5 8 = 0) into dfincac_bin.
* Egalitarianism.
recode smdfslv (1 2 = 1) (3 4 5 8 = 0) into smdfslv_bin.
fre dfincac_bin smdfslv_bin.

*** Creating the welfare regime variable (based on classification of countries by: Deeming and Jones, 2015).
compute regime = $SYSMIS.
if (cntry = "BE" or cntry = "DE" or cntry = "FR" or cntry = "CH" or cntry = "NL") regime = 1.
if (cntry = "FI" or cntry = "NO" or cntry = "SE" or cntry = "DK") regime = 2.
if (cntry = "GB" or cntry = "IE") regime = 3.
if (cntry = "ES" or cntry = "PT") regime = 4.
if (cntry = "HU" or cntry = "PL" or cntry = "SI" or cntry = "CZ" or cntry = "EE") regime = 5.
formats regime (f1.0).

variable labels regime "Welfare regime type: 5 types".
value labels regime
1"Conservative"
2"Social Democratic"
3"Liberal"
4"Mediterranean"
5"Post-Communist".
fre regime.


* This syntax creates a a basis for the table stored in "dfincac_bin.csv" file.
* This table is used to create the Figure 8 (Belief in meritocracy in Europe).
fre dfincac.
CTABLES
  /VLABELS VARIABLES=regime cntry essround dfincac_bin DISPLAY=BOTH
  /TABLE regime [C] > cntry [C] BY essround [C] > dfincac_bin [S][MEAN DOT40.2]
  /CATEGORIES VARIABLES=regime cntry essround ORDER=A KEY=VALUE EMPTY=EXCLUDE
  /CRITERIA CILEVEL=95.


* This syntax creates a a basis for the table stored in "smdfslv_bin.csv" file.
* This table is used to create the Figure 9 (Belief in egalitarianism in Europe).
fre smdfslv.
CTABLES
  /VLABELS VARIABLES=regime cntry essround smdfslv_bin DISPLAY=BOTH
  /TABLE regime [C] > cntry [C] BY essround [C] > smdfslv_bin [S][MEAN DOT40.2]
  /CATEGORIES VARIABLES=regime cntry essround ORDER=A KEY=VALUE EMPTY=EXCLUDE
  /CRITERIA CILEVEL=95.

